<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.jieSuan.yinHangZhangHuXinxi"/><spring:message code="message.jqGrid.cz.audit"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <style type="text/css">
        div.group-info {
            margin-top: 10px !important;
            margin-bottom: 0px !important;
        }
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.jieSuan.yinHangZhangHuXinxi"/><spring:message code="message.jqGrid.cz.audit"/></h1>
        <ol class="breadcrumb">
          <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.jieSuan.zhangHuGuanLi"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhangHuGuanLi"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhangHuShenHe"/></a></li>
        </ol>
     </section>
     
   
      <section class="content">
        <div class=" box box-primary ">
            <form id="form" class="form-horizontal" action="${ctx}/acctInfo/saveAuditBankAcctInfo.html" method="post" enctype="multipart/form-data" >
                <input type="hidden" id="bankAcctId" name="bankAcctId" value="${bankAcctInfo.bankAcctId}" />
                <input type="hidden" id="auditStatus" name="auditStatus" /> 
               <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="bankAcctNo" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.yinHangZhangHao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                               ${bankAcctInfo.bankAcctNo}
                        </div>
                        <label for="acctHolder" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuRen"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                               ${bankAcctInfo.acctHolder}
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="depositBank" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuHang"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                                ${fatherBankName }
                        </div>
                         <label for="acctApprovalPicDir" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuXuKeZheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                                <div style="width:0px;height:0px;overflow:hidden;">
                                    <input id="acctApprovalPicDir" name="licence" type="file" style="display:inline-block;" />
                                </div>
                                <a href="javascript:showImg('${bankAcctInfo.acctApprovalPicDir}');" style="display:inline-block;"><spring:message code="message.button.look"/></a>
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="depositBankNo" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuHangHangHao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                               ${bankAcctInfo.depositBankNo}
                        </div>
                        <label for="depositBankName" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuHangHangMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                               ${bankAcctInfo.depositBankName}
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="depositBankAreaName" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.jieSuan.kaiHuHangQuYu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                                ${bankAcctInfo.depositBankAreaName}
                        </div>
                        <label for="depositBankAreaId" class="col-sm-2 text-right" hidden="true"><spring:message code="message.jieSuan.kaiHuHangQuYu"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left" hidden="true">
                            ${bankAcctInfo.depositBankAreaId}
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="depositBankAreaId" class="col-sm-2 text-right" ><spring:message code="message.listForm.shenHeBeiZhu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-10 text-left" >
                            <textarea class="form-control" id="auditRemark" name="auditRemark"  placeholder="<spring:message code="message.listForm.shenHeBeiZhu"/>"  maxlength="512">${bankAcctInfo.auditRemark}</textarea>
                        </div>
                    </div>
                </div>    
                <div class="box-footer text-center">
                    <button type="button" class="btn btn-success btn-sm" onclick="saveBankAcctInfo(1);"><spring:message code="message.listForm.tongGuoSpacing"/></button>
                    <button type="button" class="btn btn-success btn-sm" onclick="saveBankAcctInfo(2);"><spring:message code="message.listForm.buTongGuo"/></button>
                    <a href="${ctx}/auditAcctInfo/toAuditHospAcctInfoList.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
            </form>
        </div>
    </section>   
    
    
    
    
   <%@ include file="/WEB-INF/component/commonJS.jsp"%>
   <script type="text/javascript">
   $("#bankAcctNo").focus();//加载页面光标在第一个查询框内
   
   
    //  显示许可证
        function showImg(imgPath) {
            var url = "${ctx}/acctInfo/toImg.html";
            $.HN.dialog.open({
               "id": "showImg",
               "title": "<spring:message code="message.listForm.XuKeZheng"/>", 
               "url": url, 
               "data": {"imgPath" : imgPath}, 
               "width": 800, 
               "height": 400, 
               "closefunc":function(params) {
                   if (params) {
                       
                   }
               }
           }); 
        }
    
        function selectImg() {
            $('#acctApprovalPicDir').click();
        }
   
    //支行弹窗
       function bank() {
           
           if (!validateBank()) {
               return;
           }
           
            var url = "${ctx}/acctInfo/toSubBankList.html?bankAcctNo=" + $("#depositBank").val();
           $.HN.dialog.open({
               "id": "bank",
               "title": "<spring:message code="message.jieSuan.zhiHangLieBiao"/>", 
               "url": url, 
               "data": {}, 
               "width": 800, 
               "height": 400, 
               "closefunc":function(params) {
                   if (params) {
                       $("#depositBankNo").val(params.bankCode);
                       $("#depositBankName").val(params.bankName);
                       $("#depositBankAreaName").val(params.areaName);
                       $("#depositBankAreaId").val(params.areaCode);
                   }
               }
           }); 
       }
       
     //支行效验
       function validateBank() {
           var depositBank = $.trim($("#depositBank").val());
           if (depositBank == null || depositBank == "") {
        	   $.HN.message.alert("<spring:message code="message.select.option"/><spring:message code="message.jieSuan.kaiHuHang"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           return true;
       }
       
       
     //审核
       function saveBankAcctInfo(auditStatus) {
          /*  if (!validate()) {
               return;
           } */
           $("#auditStatus").val(auditStatus);
           if(auditStatus == 2){
			   var auditRemarkText = $.trim($("#auditRemark").val());
			   if("" == auditRemarkText || null == auditRemarkText){
					 $.HN.message.alert("<spring:message code="message.jieSuan.shenHeBuTongGuoBeiZhu"/>",  "<spring:message code="message.HN.alert.type"/>", "");
					 return;
			   }
        	   
           }
           $.HN.message.confirm("<spring:message code="message.HN.alert.OkSaveYESorNO"/>", "<spring:message code="message.HN.alert.tiShiXinXi"/>", "<spring:message code="message.lable.OKYES"/>").on(function(bool) {
               if (bool) {
                   $("#form").ajaxSubmit({ 
                       dataType : "json",
                       timeout: 10000,
                       success : function(result, statusText) {
                           if (result.success) {
                        	   $.HN.message.alert("<spring:message code="message.jieSuan.tiJiaoChengGong"/>", "<spring:message code="message.HN.alert.type"/>", "success", function() {
                                   document.location = "${ctx}/auditAcctInfo/toAuditHospAcctInfoList.html?orgId=${orgId}";
                               });
                           } else {
                        	   $.HN.message.alert(result.msg || "<spring:message code="message.jieSuan.tiJiaoShiBai"/>",  "<spring:message code="message.HN.alert.type"/>", "error");
                           }
                       }
                   });
               }
           });
       }
     
     
       //提交效验
       function validate() {
    	   var bankAcctNo = $.trim($("#bankAcctNo").val());
           if (bankAcctNo == null || bankAcctNo == "") {
               $.HN.message.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.jieSuan.yinHangZhangHao"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           } else if (!/^\d+$/.test(bankAcctNo)) {
               $.HN.message.alert("<spring:message code="message.jieSuan.yinHangZhangHao"/><spring:message code="message.lable.daYuLingDeShu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false ;
           } else if (bankAcctNo.length>36){
               $.HN.message.alert("<spring:message code="message.jieSuan.yinHangZhangHao"/><spring:message code="message.info.zuiDaChangDu"/>36<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return  false;
           }
           
           var acctHolder = $.trim($("#acctHolder").val());
           if (acctHolder == null || acctHolder == "") {
               $.HN.message.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.jieSuan.kaiHuRen"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           } else if (acctHolder.length>256){
               $.HN.message.alert("<spring:message code="message.jieSuan.kaiHuRen"/><spring:message code="message.info.zuiDaChangDu"/>256<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return  false;
           }
           
           var depositBank = $.trim($("#depositBank").val());
           if (depositBank == null || depositBank == "") {
               $.HN.message.alert("<spring:message code="message.select.option"/><spring:message code="message.jieSuan.kaiHuHang"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           
           if ("${bankAcctInfo.bankAcctId == null}" == "true") {
               var acctApprovalPicDir = $.trim($("#acctApprovalPicDir").val());
               if (acctApprovalPicDir == null || acctApprovalPicDir == "") {
                   $.HN.message.alert("<spring:message code="message.jieSuan.shangChuanKaiHuXuKeZheng"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
                   return false;
               }
           }
           
           var depositBankNo = $.trim($("#depositBankNo").val());
           if (depositBankNo == null || depositBankNo == "") {
               $.HN.message.alert("<spring:message code="message.select.option"/><spring:message code="message.jieSuan.kaiHuHangHangHao"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           
           var depositBankName = $.trim($("#depositBankName").val());
           if (depositBankName == null || depositBankName == "") {
               $.HN.message.alert("<spring:message code="message.select.option"/><spring:message code="message.jieSuan.kaiHuHangHangMing"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           
           var depositBankAreaName = $.trim($("#depositBankAreaName").val());
           if (depositBankAreaName == null || depositBankAreaName == "") {
               $.HN.message.alert("<spring:message code="message.select.option"/><spring:message code="message.jieSuan.kaiHuHangQuYu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           var auditRemark = $.trim($("#auditRemark").val());
           if (auditRemark.length>1024) {
               $.HN.message.alert("<spring:message code="message.listForm.shenHeBeiZhu"/><spring:message code="message.info.zuiDaChangDu"/>1024<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           
           var exists = false;
           $.ajax({
               type: "post",
               url: "${ctx}/acctInfo/checkSameBankAcctNo.html",
               data: {
                   bankAcctId : $("#bankAcctId").val(),
                   bankAcctNo : bankAcctNo
               },
               async: false,
               success: function(data, textStatus){
                   var json = eval('(' + data + ')');
                   exists = json.success;
               }
           });
           if (exists) {
        	   $.HN.message.alert("<spring:message code="message.jieSuan.yinHangZhangHao"/><spring:message code="message.lable.yiChunZai"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return false;
           }
           
           return true;
       }
        
       $(document).ready(function(){
           $("#depositBank").change(function(){
               $("#depositBankNo").val("");
               $("#depositBankName").val("");
               $("#depositBankAreaName").val("");
               $("#depositBankAreaId").val("");
           });
       });
   </script>
        
</body>
</html>
